itextsharp editor for creating tags

╄→尐↘猪︶ㄣ 提交于 2019-12-24 02:39:35

问题


I would like to know if exist some program for editing itextsharp code.

Now I am writting code directly in VS lile:

// Delivery address details
int left_margin = 40;
int top_margin = 720;
writeText(cb, "Delivery address", left_margin, top_margin, f_cb, 10);
writeText(cb, drHead["delCustomerName"].ToString(), left_margin, top_margin-12, f_cn, 10);
writeText(cb, drHead["delAddress1"].ToString(), left_margin, top_margin-24, f_cn, 10);
writeText(cb, drHead["delAddress2"].ToString(), left_margin, top_margin-36, f_cn, 10);
writeText(cb, drHead["delAddress3"].ToString(), left_margin, top_margin-48, f_cn, 10);
writeText(cb, drHead["delZipcode"].ToString(), left_margin, top_margin-60, f_cn, 10);
writeText(cb, drHead["delCity"].ToString() + ", " + drHead["delCountry"].ToString(), left_margin+65, top_margin-60, f_cn, 10);

But I would like to use some editor for this because this is horrible to write by hand. I am searching for an editor but I can not find it.


回答1:


I'm guessing that you inherited some code, right? I say that because writeText() is not from iTextSharp, it is someone's specific implementation that wraps around iTextSharp's code.

iTextSharp is a library that ultimately produces PDFs and as such is bound by the PDF specification. This is first and foremost the most important thing to understand. Even if you already know this you must always keep this top of mind.

iText runs in two basic modes, 1) full abstraction where you add "paragraphs" and "tables" and 2) manual placement mode where you say "write this text using this font at this coordinate and don't worry, I've measured everything so I know where to insert line breaks so it doesn't look weird."

Full abstraction mode (my terminology, not their's) uses the Document object and you create new Paragraph objects and Add them to the Document and iText figures the rest out for you. There's less control but if you can live in this mode your live will be so much easier.

Manual placement mode (once again, my terminology, not their's) uses instances of the PdfWriter and PdfContentByte classes to issue commands that are much closer to the PDF spec. Usage of this mode kind of assumes that you've at least partially read the spec. For instance, you'll should be aware that "paragraphs" and "tables" don't actually exist in a PDF.

The variable that you are using, cb, is almost definitely an instance of a PdfContentByte so you are using manual placement mode.

Now to answer your question.

No, there are no GUI programs to edit code that's specific to iTextSharp. However, there are programs such as Adobe Acrobat, Adobe Illustrator and Adobe InDesign that do know how to work with PDFs. There are probably free ones out there, too. You can use these programs, find the x,y coordinates of things and manually write those into your code.



来源:https://stackoverflow.com/questions/27365627/itextsharp-editor-for-creating-tags

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!