PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Invisible paragraph https://forum.pdfsharp.net/viewtopic.php?f=2&t=3640 |
Page 1 of 1 |
Author: | MariusIonut [ Mon Aug 14, 2017 6:08 am ] |
Post subject: | Invisible paragraph |
It is possible to add an invisible text in the page without modifying the layout of the rest of the items. Reason: I use hidden text as bookmark in XPS document to pin point the document viewer to the exact location of a paragraph, table, image and I need to make something hidden, adding a paragraph and modifying the style or any other option to 0 still creates a small gap between the items. |
Author: | Thomas Hoevel [ Mon Aug 14, 2017 7:43 am ] |
Post subject: | Re: Invisible paragraph |
Using a font size of e.g. 0.001 with white text color (assuming pages are white) or 100% transparency will make the text virtually invisible. It's a hack, but I get "invisible" bookmarks this way. I do not fully understand what you need. Maybe an empty paragraph can be used to get a clean solution. You can use the Tag property of the paragraph to identify it. |
Author: | MariusIonut [ Mon Aug 14, 2017 11:16 am ] |
Post subject: | Re: Invisible paragraph |
I have being doing that but adding a paragraph with an invisible text (font size =0.01 and white font color) will still reserve in the final document a few millimeters. It is for a project where i have a document structure made in a tree view something like: chapter -chapter --paragraph --paragraph -chapter .... And whenever I click one of the items from the treeview I want the document viewer to move to the corresponding document component in the viewer. And one way of doing, as far I could think of, is to search in the generated XPS document the hacky bookmark that I made with invisible text but doing those kind of invisible paragraphs alters the layout of other component by few millimeters. |
Author: | Thomas Hoevel [ Mon Aug 14, 2017 1:42 pm ] |
Post subject: | Re: Invisible paragraph |
MariusIonut wrote: I have being doing that but adding a paragraph with an invisible text (font size =0.01 and white font color) will still reserve in the final document a few millimeters. Not when you do it the right way. You can (and should) set the absolute height of the paragraph.Code: paragraph.Format.LineSpacingRule = LineSpacingRule.Exactly; You may have to set SpaceBefore and SpaceAfter to 0.
paragraph.Format.LineSpacing = 0.001; |
Author: | MariusIonut [ Tue Aug 22, 2017 7:34 am ] |
Post subject: | Re: Invisible paragraph |
Hello Thomas, Sorry for late response, I was on a small vacation. Even with your latest suggestion it is still somehow reserving space. Here are the DDLs: Wanted layout: (No hidden paragraphs) Code: \document { \styles { Normal { Font { Name = "Times New Roman" } ParagraphFormat { LeftIndent = "0mm" FirstLineIndent = "0mm" RightIndent = "0mm" SpaceBefore = "4mm" SpaceAfter = "4mm" LineSpacing = "0mm" } } HiddenBookmark : Normal { Font { Size = 0.01 } ParagraphFormat { SpaceBefore = "0mm" SpaceAfter = "0mm" LineSpacingRule = Exactly LineSpacing = "0.001mm" KeepTogether = false KeepWithNext = false } } Paragraph : Normal { } } \section [ PageSetup { PageHeight = 842 PageWidth = 595 Orientation = Portrait LeftMargin = "20mm" RightMargin = "16mm" TopMargin = "15mm" BottomMargin = "20mm" FooterDistance = "10mm" HeaderDistance = "8mm" OddAndEvenPagesHeaderFooter = false DifferentFirstPageHeaderFooter = false SectionStart = BreakNextPage PageFormat = A4 MirrorMargins = false HorizontalPageBreak = false } ] { \paragraph [ Style = "Paragraph" Format { LeftIndent = 0 RightIndent = 0 } ] { \font("Normal"){asdasd} } \paragraph [ Style = "Paragraph" Format { LeftIndent = 0 RightIndent = 0 } ] { \font("Normal"){asdasda} } } } Actual layout:(with hidden paragraph) Code: \document { \styles { Normal { Font { Name = "Times New Roman" } ParagraphFormat { LeftIndent = "0mm" FirstLineIndent = "0mm" RightIndent = "0mm" SpaceBefore = "4mm" SpaceAfter = "4mm" LineSpacing = "0mm" } } HiddenBookmark : Normal { Font { Size = 0.01 } ParagraphFormat { SpaceBefore = "0mm" SpaceAfter = "0mm" LineSpacingRule = Exactly LineSpacing = "0.001mm" KeepTogether = false KeepWithNext = false } } Paragraph : Normal { } } \section [ PageSetup { PageHeight = 842 PageWidth = 595 Orientation = Portrait LeftMargin = "20mm" RightMargin = "16mm" TopMargin = "15mm" BottomMargin = "20mm" FooterDistance = "10mm" HeaderDistance = "8mm" OddAndEvenPagesHeaderFooter = false DifferentFirstPageHeaderFooter = false SectionStart = BreakNextPage PageFormat = A4 MirrorMargins = false HorizontalPageBreak = false } ] { \paragraph [ Style = "HiddenBookmark" ] { | →ParagraphCommandxELEMENTxUNIQUExIDx1 | } \paragraph [ Style = "Paragraph" Format { LeftIndent = 0 RightIndent = 0 } ] { \font("Normal"){asdasd} } \paragraph [ Style = "HiddenBookmark" ] { | →ParagraphCommandxELEMENTxUNIQUExIDx2 | } \paragraph [ Style = "Paragraph" Format { LeftIndent = 0 RightIndent = 0 } ] { \font("Normal"){asdasds} } } } Changing the space before and space after for style Paragraph to 0 creates the correct layout, but when any other value is used (in my case is inherited from NORMAL style) then the space after and before doubles. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |