first working self-contained build!
This commit is contained in:
		
							parent
							
								
									3d4e6cf1bb
								
							
						
					
					
						commit
						bc3ff140b1
					
				
							
								
								
									
										3685
									
								
								output.pdf
								
								
								
								
							
							
						
						
									
										3685
									
								
								output.pdf
								
								
								
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -30,7 +30,6 @@ const TextCard = struct { | ||||||
|     lines: [][]const u8 = undefined, |     lines: [][]const u8 = undefined, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| //dimension constants and defaults | //dimension constants and defaults | ||||||
| const cardWidth = 30; | const cardWidth = 30; | ||||||
| const cardHeight = 32; | const cardHeight = 32; | ||||||
|  | @ -108,11 +107,27 @@ pub fn main() !void { | ||||||
|     } else { |     } else { | ||||||
|         try cardRow.print(allocator, rowToPrint.items, &allPrinted); |         try cardRow.print(allocator, rowToPrint.items, &allPrinted); | ||||||
|         std.debug.print("{s}", .{allPrinted.items}); |         std.debug.print("{s}", .{allPrinted.items}); | ||||||
|         const page = c.pdf_append_page(pdf_doc); |         //TODO (fixme): | ||||||
|         _ = c.pdf_add_text(pdf_doc, page, @ptrCast(allPrinted.items[0..10]), 12, 10, c.PDF_A4_HEIGHT - 12, c.PDF_BLACK); |         // wrong type error when not using ptrCast, nothing printed when using it | ||||||
|         _ = c.pdf_add_text(pdf_doc, page, "HELLO WEST VIRGINIA", 12, 10, c.PDF_A4_HEIGHT - 12, c.PDF_BLACK); |         // _ = c.pdf_add_text(pdf_doc, page, allPrinted.items[0..50], 12, 10, c.PDF_A4_HEIGHT - 12, c.PDF_BLACK); | ||||||
|  |         // _ = c.pdf_add_text(pdf_doc, page, allPrinted.items[0..50], 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(); |         rowToPrint.clearAndFree(); | ||||||
|     } |     } | ||||||
|  |     var rowsPrinted: f32 = 0; | ||||||
|  |     var page = c.pdf_append_page(pdf_doc); | ||||||
|  |     var textIterator = std.mem.splitAny(u8, allPrinted.items, "\n"); | ||||||
|  |     _ = c.pdf_set_font(pdf_doc, "Courier"); | ||||||
|  |     while (textIterator.next()) |text| { | ||||||
|  |         if (rowsPrinted < pageHeight) { | ||||||
|  |             rowsPrinted += 1; | ||||||
|  |             _ = c.pdf_add_text(pdf_doc, page, try std.mem.Allocator.dupeZ(allocator, u8, text), 8, 10, c.PDF_A4_HEIGHT - (12 * rowsPrinted), c.PDF_BLACK); | ||||||
|  |         } else { | ||||||
|  |             rowsPrinted = 1; | ||||||
|  |             page = c.pdf_append_page(pdf_doc); | ||||||
|  |             _ = c.pdf_add_text(pdf_doc, page, try std.mem.Allocator.dupeZ(allocator, u8, text), 8, 10, c.PDF_A4_HEIGHT - (12 * rowsPrinted), c.PDF_BLACK); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     _ = c.pdf_save(pdf_doc, "output.pdf"); |     _ = c.pdf_save(pdf_doc, "output.pdf"); | ||||||
|     _ = c.pdf_destroy(pdf_doc); |     _ = c.pdf_destroy(pdf_doc); | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue