summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 83ff7f0)
raw | patch | inline | side by side (parent: 83ff7f0)
author | ulferikson <ulferikson@users.sourceforge.net> | |
Sat, 5 Aug 2006 21:04:37 +0000 (21:04 +0000) | ||
committer | ulferikson <ulferikson@users.sourceforge.net> | |
Sat, 5 Aug 2006 21:04:37 +0000 (21:04 +0000) |
src/extension/internal/pdf-mini.h | patch | blob | history | |
src/extension/internal/pdf.cpp | patch | blob | history |
index 62b03a8f21bd5ae0225a2d1dd76f180fbfabedbf..d0b4ea1f1fbaf878e24a2112c475c25feeea3ae4 100644 (file)
<< " /Length " << obj_length->get_id() << " 0 R\n"\r
<< ">>\n"\r
<< "stream\n";\r
- stream_pos = obj_contents->get_length();\r
+ puts(obj_contents);\r
+ stream_pos = ftell(fp);\r
\r
return obj_contents;\r
}\r
\r
void PdfFile::end_page(PdfObject *page) {\r
- long stream_length = page->get_length() - stream_pos;\r
+ long stream_length = ftell(fp) - stream_pos;\r
\r
- *page << "endstream\n";\r
- end_object(page);\r
- puts(page);\r
+ puts("endstream\n");\r
+ puts("endobj\n");\r
\r
*obj_length << stream_length << "\n";\r
end_object(obj_length);\r
index 796e410cbfe2df2b21a30191a22b9bbbe9f83af5..2e8d8813b21394fc1677f20ff8f907d0ce37b3d9 100644 (file)
(int) d.x1, (int) d.y1 );\r
\r
if (!_bitmap) {\r
- *page_stream << PT_PER_PX << " 0 0 "\r
- << -PT_PER_PX << " 0 " << (int) ceil(_height)\r
- << " cm\n";\r
+ Inkscape::SVGOStringStream os;\r
+ os.setf(std::ios::fixed);\r
+ os << PT_PER_PX << " 0 0 "\r
+ << -PT_PER_PX << " 0 " << (int) ceil(_height)\r
+ << " cm\n";\r
// from now on we can output px, but they will be treated as pt\r
+ pdf_file->puts(os);\r
}\r
\r
return 1;\r
@@ -472,13 +475,16 @@ PrintPDF::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.\r
if (_bitmap) return 0;\r
\r
- *page_stream << "q\n";\r
- *page_stream << transform->c[0] << " "\r
- << transform->c[1] << " "\r
- << transform->c[2] << " "\r
- << transform->c[3] << " "\r
- << transform->c[4] << " "\r
- << transform->c[5] << " cm\n";\r
+ Inkscape::SVGOStringStream os;\r
+ os.setf(std::ios::fixed);\r
+ \r
+ os << "q\n";\r
+ os << transform->c[0] << " "\r
+ << transform->c[1] << " "\r
+ << transform->c[2] << " "\r
+ << transform->c[3] << " "\r
+ << transform->c[4] << " "\r
+ << transform->c[5] << " cm\n";\r
\r
float alpha = opacity * _pushed_alphas[_curr_alpha];\r
\r
@@ -489,6 +495,7 @@ PrintPDF::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float
}\r
_pushed_alphas[_curr_alpha] = alpha;\r
\r
+ pdf_file->puts(os);\r
return 1;\r
}\r
\r
if (_curr_alpha > 0)\r
_curr_alpha--;\r
\r
- *page_stream << "Q\n";\r
+ pdf_file->puts("Q\n");\r
\r
return 1;\r
}\r
{\r
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.\r
if (_bitmap) return 0;\r
-\r
- *page_stream << "% " << comment;\r
\r
return 1;\r
}\r
\r
void\r
-PrintPDF::print_fill_alpha(SVGOStringStream &/*os*/, SPStyle const *const style, NRRect const *pbox)\r
+PrintPDF::print_fill_alpha(SVGOStringStream &os, SPStyle const *const style, NRRect const *pbox)\r
{\r
g_return_if_fail( style->fill.type == SP_PAINT_TYPE_COLOR\r
|| ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER\r
@@ -536,8 +541,8 @@ PrintPDF::print_fill_alpha(SVGOStringStream &/*os*/, SPStyle const *const style,
*pdf_alpha << " /AIS false\n";\r
*pdf_alpha << ">>\n";\r
\r
- *page_stream << pdf_alpha->get_name()\r
- << " gs\n";\r
+ os << pdf_alpha->get_name()\r
+ << " gs\n";\r
\r
pdf_file->end_resource(pdf_alpha);\r
}\r
@@ -668,7 +673,7 @@ PrintPDF::print_fill_alpha(SVGOStringStream &/*os*/, SPStyle const *const style,
\r
*pdf_gstate << ">>\n";\r
\r
- *page_stream << pdf_gstate->get_name() << " gs\n";\r
+ os << pdf_gstate->get_name() << " gs\n";\r
\r
pdf_file->end_resource(pdf_gstate);\r
}\r
@@ -798,7 +803,7 @@ PrintPDF::print_fill_alpha(SVGOStringStream &/*os*/, SPStyle const *const style,
\r
*pdf_gstate << ">>\n";\r
\r
- *page_stream << pdf_gstate->get_name() << " gs\n";\r
+ os << pdf_gstate->get_name() << " gs\n";\r
\r
pdf_file->end_resource(pdf_gstate);\r
}\r
@@ -817,7 +822,7 @@ PrintPDF::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRR
float rgb[3];\r
sp_color_get_rgb_floatv(&style->fill.value.color, rgb);\r
\r
- *page_stream << rgb[0] << " " << rgb[1] << " " << rgb[2] << " rg\n";\r
+ os << rgb[0] << " " << rgb[1] << " " << rgb[2] << " rg\n";\r
} else {\r
g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER\r
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );\r
@@ -864,7 +869,7 @@ PrintPDF::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRR
}\r
*pdf_shade << "]\n";\r
*pdf_shade << ">>\n>>\n";\r
- *page_stream << pdf_shade->get_name() << " ";\r
+ os << pdf_shade->get_name() << " ";\r
\r
pdf_file->end_resource(pdf_shade);\r
} else if (SP_IS_RADIALGRADIENT (SP_STYLE_FILL_SERVER (style))) {\r
@@ -913,7 +918,7 @@ PrintPDF::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRR
*pdf_shade << "]\n";\r
*pdf_shade << ">>\n>>\n";\r
\r
- *page_stream << pdf_shade->get_name() << " ";\r
+ os << pdf_shade->get_name() << " ";\r
\r
pdf_file->end_resource(pdf_shade);\r
}\r
float rgb[3];\r
\r
sp_color_get_rgb_floatv(&style->stroke.value.color, rgb);\r
- *page_stream << rgb[0] << " " << rgb[1] << " " << rgb[2] << " RG\n";\r
+ os << rgb[0] << " " << rgb[1] << " " << rgb[2] << " RG\n";\r
\r
float alpha = 1.0;\r
alpha *= SP_SCALE24_TO_FLOAT(style->stroke_opacity.value);\r
*pdf_alpha << " /AIS false\n";\r
*pdf_alpha << ">>\n";\r
\r
- *page_stream << pdf_alpha->get_name() << " gs\n";\r
+ os << pdf_alpha->get_name() << " gs\n";\r
\r
pdf_file->end_resource(pdf_alpha);\r
}\r
i++;\r
}\r
if (!LineSolid) {\r
- *page_stream << "[";\r
+ os << "[";\r
for (i = 0; i < style->stroke_dash.n_dash; i++) {\r
if (i > 0) {\r
- *page_stream << " ";\r
+ os << " ";\r
}\r
- *page_stream << style->stroke_dash.dash[i];\r
+ os << style->stroke_dash.dash[i];\r
}\r
- *page_stream << "] " << style->stroke_dash.offset << " d\n";\r
+ os << "] " << style->stroke_dash.offset << " d\n";\r
} else {\r
- *page_stream << "[] 0 d\n";\r
+ os << "[] 0 d\n";\r
}\r
} else {\r
- *page_stream << "[] 0 d\n";\r
+ os << "[] 0 d\n";\r
}\r
\r
- *page_stream << style->stroke_width.computed << " w\n";\r
- *page_stream << style->stroke_linejoin.computed << " j\n";\r
- *page_stream << style->stroke_linecap.computed << " J\n";\r
- *page_stream <<\r
+ os << style->stroke_width.computed << " w\n";\r
+ os << style->stroke_linejoin.computed << " j\n";\r
+ os << style->stroke_linecap.computed << " J\n";\r
+ os <<\r
( style->stroke_miterlimit.value > 1 ?\r
style->stroke_miterlimit.value : 1 ) << " M\n";\r
}\r
@@ -993,68 +998,69 @@ PrintPDF::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix c
if (_bitmap) return 0;\r
\r
if ( style->fill.type == SP_PAINT_TYPE_COLOR ) {\r
- *page_stream << "q\n";\r
+ os << "q\n";\r
print_fill_style(os, style, pbox);\r
print_fill_alpha(os, style, pbox);\r
print_bpath(os, bpath->path);\r
if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {\r
- *page_stream << "f*\n";\r
+ os << "f*\n";\r
} else {\r
- *page_stream << "f\n";\r
+ os << "f\n";\r
}\r
- *page_stream << "Q\n";\r
+ os << "Q\n";\r
}\r
else if ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER\r
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) )\r
{\r
- *page_stream << "q\n";\r
+ os << "q\n";\r
print_bpath(os, bpath->path);\r
\r
if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {\r
g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER\r
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );\r
SPGradient const *g = SP_GRADIENT(SP_STYLE_FILL_SERVER(style));\r
- *page_stream << "W* n\n";\r
+ os << "W* n\n";\r
print_fill_alpha(os, style, pbox);\r
if (g->gradientTransform_set) {\r
- *page_stream << "q\n";\r
- *page_stream << g->gradientTransform[0] << " "\r
- << g->gradientTransform[1] << " "\r
- << g->gradientTransform[2] << " "\r
- << g->gradientTransform[3] << " "\r
- << g->gradientTransform[4] << " "\r
- << g->gradientTransform[5] << " cm\n";\r
+ os << "q\n";\r
+ os << g->gradientTransform[0] << " "\r
+ << g->gradientTransform[1] << " "\r
+ << g->gradientTransform[2] << " "\r
+ << g->gradientTransform[3] << " "\r
+ << g->gradientTransform[4] << " "\r
+ << g->gradientTransform[5] << " cm\n";\r
}\r
print_fill_style(os, style, pbox);\r
- *page_stream << "sh\n";\r
+ os << "sh\n";\r
if (g->gradientTransform_set) {\r
- *page_stream << "Q\n";\r
+ os << "Q\n";\r
}\r
} else {\r
g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER\r
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );\r
SPGradient const *g = SP_GRADIENT(SP_STYLE_FILL_SERVER(style));\r
- *page_stream << "W n\n";\r
+ os << "W n\n";\r
print_fill_alpha(os, style, pbox);\r
if (g->gradientTransform_set) {\r
- *page_stream << "q\n";\r
- *page_stream << g->gradientTransform[0] << " "\r
- << g->gradientTransform[1] << " "\r
- << g->gradientTransform[2] << " "\r
- << g->gradientTransform[3] << " "\r
- << g->gradientTransform[4] << " "\r
- << g->gradientTransform[5] << " cm\n"; \r
+ os << "q\n";\r
+ os << g->gradientTransform[0] << " "\r
+ << g->gradientTransform[1] << " "\r
+ << g->gradientTransform[2] << " "\r
+ << g->gradientTransform[3] << " "\r
+ << g->gradientTransform[4] << " "\r
+ << g->gradientTransform[5] << " cm\n"; \r
}\r
print_fill_style(os, style, pbox);\r
- *page_stream << "sh\n";\r
+ os << "sh\n";\r
if (g->gradientTransform_set) {\r
- *page_stream << "Q\n";\r
+ os << "Q\n";\r
}\r
}\r
\r
- *page_stream << "Q\n";\r
+ os << "Q\n";\r
} \r
\r
+ pdf_file->puts(os);\r
return 0;\r
}\r
\r
@@ -1070,13 +1076,15 @@ PrintPDF::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix
Inkscape::SVGOStringStream os;\r
os.setf(std::ios::fixed);\r
\r
- *page_stream << "q\n";\r
+ os << "q\n";\r
\r
print_stroke_style(os, style);\r
print_bpath(os, bpath->path);\r
- *page_stream << "S\n";\r
+ os << "S\n";\r
+\r
+ os << "Q\n";\r
\r
- *page_stream << "Q\n";\r
+ pdf_file->puts(os);\r
}\r
\r
return 0;\r
switch (bp->code) {\r
case NR_MOVETO:\r
if (closed) {\r
- *page_stream << "h\n";\r
+ os << "h\n";\r
}\r
closed = true;\r
- *page_stream << bp->x3 << " " << bp->y3 << " m\n";\r
+ os << bp->x3 << " " << bp->y3 << " m\n";\r
break;\r
case NR_MOVETO_OPEN:\r
if (closed) {\r
- *page_stream << "h\n";\r
+ os << "h\n";\r
}\r
closed = false;\r
- *page_stream << bp->x3 << " " << bp->y3 << " m\n";\r
+ os << bp->x3 << " " << bp->y3 << " m\n";\r
break;\r
case NR_LINETO:\r
- *page_stream << bp->x3 << " " << bp->y3 << " l\n";\r
+ os << bp->x3 << " " << bp->y3 << " l\n";\r
break;\r
case NR_CURVETO:\r
- *page_stream << bp->x1 << " " << bp->y1 << " "\r
+ os << bp->x1 << " " << bp->y1 << " "\r
<< bp->x2 << " " << bp->y2 << " "\r
<< bp->x3 << " " << bp->y3 << " c\n";\r
break;\r
bp += 1;\r
}\r
if (closed) {\r
- *page_stream << "h\n";\r
+ os << "h\n";\r
}\r
}\r
\r