futzing around trying to hold on to the text value to pass to pdfgen
This commit is contained in:
		
							parent
							
								
									de346901ec
								
							
						
					
					
						commit
						3d4e6cf1bb
					
				|  | @ -1,2 +1,3 @@ | |||
| zig-cache/ | ||||
| zig-out/ | ||||
| .zig-cache/ | ||||
|  |  | |||
							
								
								
									
										10
									
								
								output.pdf
								
								
								
								
							
							
						
						
									
										10
									
								
								output.pdf
								
								
								
								
							|  | @ -3,7 +3,7 @@ | |||
| 1 0 obj | ||||
| << | ||||
|   /Creator (My Software                                                    ) | ||||
|   /CreationDate (D:20240708145522Z) | ||||
|   /CreationDate (D:20240708151335Z) | ||||
| >> | ||||
| endobj | ||||
| 2 0 obj | ||||
|  | @ -61,8 +61,8 @@ endobj | |||
| >> | ||||
| endobj | ||||
| 6 0 obj | ||||
| << /Length 114 >>stream | ||||
| BT /GS0 gs 10.000000 100.000000 TD /F1 12.000000 Tf 0.000000 0.000000 0.000000 rg 0.000000 Tc (This is text) Tj ET | ||||
| << /Length 121 >>stream | ||||
| BT /GS0 gs 10.000000 829.889771 TD /F1 12.000000 Tf 0.000000 0.000000 0.000000 rg 0.000000 Tc (HELLO WEST VIRGINIA) Tj ET | ||||
| endstream | ||||
| endobj | ||||
| xref | ||||
|  | @ -79,8 +79,8 @@ trailer | |||
| /Size 7 | ||||
| /Root 3 0 R | ||||
| /Info 1 0 R | ||||
| /ID [<63293df1587875a0> <001ae54cf88cf643>] | ||||
| /ID [<e45ab55da870297f> <001ae7fada3449ec>] | ||||
| >> | ||||
| startxref | ||||
| 1254 | ||||
| 1261 | ||||
| %%EOF | ||||
|  |  | |||
|  | @ -36,7 +36,7 @@ const cardWidth = 30; | |||
| const cardHeight = 32; | ||||
| const minCardHeight = 5; | ||||
| const pageHeight = 66; | ||||
| var heightMayVary = false; | ||||
| var heightMayVary = true; | ||||
| 
 | ||||
| const formatString = "{s: <" ++ std.fmt.digits2(cardWidth) ++ "}"; | ||||
| const lineFormatter = "|" ++ formatString; | ||||
|  | @ -64,13 +64,6 @@ pub fn main() !void { | |||
|     var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | ||||
|     defer arena.deinit(); | ||||
|     const allocator = arena.allocator(); | ||||
|     const pdf_doc: *c.pdf_doc = @ptrCast(c.pdf_create(c.PDF_A4_WIDTH, c.PDF_A4_HEIGHT, &c.pdf_info{.creator = ("My Software" ++ " " ** 53).* }).?); | ||||
|     _ = c.pdf_set_font(pdf_doc, "Times-Roman"); | ||||
|     const page = c.pdf_append_page(pdf_doc); | ||||
|     _ = c.pdf_add_text(pdf_doc, page, "This is text", 12, 10, 100, c.PDF_BLACK); | ||||
|     // _ = c.pdf_add_line(pdf_doc, null, 50, 24, 150, 24, 3, c.PDF_BLACK); | ||||
|     _ = c.pdf_save(pdf_doc, "output.pdf"); | ||||
|     _ = c.pdf_destroy(pdf_doc); | ||||
| 
 | ||||
|     const oracleFile = try cwd.openFile(oracleFileName, .{}); | ||||
|     var jsonReader = json.reader(allocator, oracleFile.reader()); | ||||
|  | @ -101,6 +94,9 @@ pub fn main() !void { | |||
| 
 | ||||
|     var allPrinted = std.ArrayList(u8).init(allocator); | ||||
| 
 | ||||
|     const pdf_doc: *c.pdf_doc = @ptrCast(c.pdf_create(c.PDF_A4_WIDTH, c.PDF_A4_HEIGHT, &c.pdf_info{.creator = ("My Software" ++ " " ** 53).* }).?); | ||||
|     _ = c.pdf_set_font(pdf_doc, "Times-Roman"); | ||||
| 
 | ||||
|     var rowToPrint = std.ArrayList(TextCard).init(allocator); | ||||
|     // var cardIterator = cards.valueIterator(); | ||||
|     for (cards.values()) |cardText| { | ||||
|  | @ -112,8 +108,14 @@ pub fn main() !void { | |||
|     } else { | ||||
|         try cardRow.print(allocator, rowToPrint.items, &allPrinted); | ||||
|         std.debug.print("{s}", .{allPrinted.items}); | ||||
|         const page = c.pdf_append_page(pdf_doc); | ||||
|         _ = c.pdf_add_text(pdf_doc, page, @ptrCast(allPrinted.items[0..10]), 12, 10, c.PDF_A4_HEIGHT - 12, c.PDF_BLACK); | ||||
|         _ = c.pdf_add_text(pdf_doc, page, "HELLO WEST VIRGINIA", 12, 10, c.PDF_A4_HEIGHT - 12, c.PDF_BLACK); | ||||
|         rowToPrint.clearAndFree(); | ||||
|     } | ||||
| 
 | ||||
|     _ = c.pdf_save(pdf_doc, "output.pdf"); | ||||
|     _ = c.pdf_destroy(pdf_doc); | ||||
| } | ||||
| 
 | ||||
| fn card( | ||||
|  |  | |||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue