create pdf with long lines, fit to pagewidth without wordwrap - pdf

i'd like to create a large pdf (not typical page size) with long lines, max ~1000 characters / line, where the page size and font are such that no lines need to wrap.
the intention is not for the text in this document to be readable when the full page is viewed on any reasonably-sized monitor -- instead the reader can zoom to individual portions of interest within the document.
i attempted this with a small font in latex, but no success.
any help is greatly appreciated. thanks.

This works with pdflatex:
\documentclass{article}
\pdfpagewidth 200cm
\pdfpageheight 200cm
\textwidth 190cm
\def\lorem{Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.}
\begin{document}
\lorem \lorem \lorem \lorem
\end{document}

Related

How can I inject fonts and colour variables (fetched from backend api upon page load) into Nuxt.js styles?

I am building an application in Nuxt.js where each clients can configure custom fonts & colours depending on their brand. Clients can specify upto 3 fonts and 3 colours, which are exposed to the front-end via an api endpoint:
Fonts:
primary-font
secondary-font
tertiary-font
Colours:
primary-colour
seconday-colour
tertiary-colour
How can I inject these fonts and colours into the application when a user visits the clients link https://{client-slug}.{domain}.com ?
You can construct a FontFace object and inject it to the document.
Following are the example of how you can achieve it. You can run the code snippet:
const fontFamily = 'Sansita Swashed'; // your custom font family
const fontSrc = 'https://fonts.gstatic.com/s/sansitaswashed/v1/BXR8vFfZifTZgFlDDLgNkBydPKTt3pVCeYWqJnZSW7RpXTIfeymE.woff2' // your custom font source
function injectCustomFont() {
const customFont = new FontFace(fontFamily, `url(${fontSrc})`);
customFont.load().then((font) => {
document.fonts.add(font);
document.body.style.fontFamily = '"Sansita Swashedr", cursive';
});
}
document.getElementById('btnFontChanger').addEventListener('click', () => {
injectCustomFont();
});
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<button id="btnFontChanger" type="button">Click to change font</button>
FontFace() constructor can accept one more parameter. Learn more at here.
Note:
FontFace is still an experimental. You must double check the browser compatibility before using it.
Relatable links:
https://usefulangle.com/post/74/javascript-dynamic-font-loading
https://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFace

XSLT value-of not showing new paragraphs

I have problem of getting text from xml in original state.
When I use <xsl:value-of select="desc" /> I get full text, but merged, without spaces between paragraphs.
I have data like this:
<desc><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat]]>
</desc>
And, as output I get this:
This is not good for me, because I want output text to be same as inside CDATA[], with blank lines between paragraphs.
I tried with using preserved spaces.
I'm using Saxon xslt processor
Using fo:block linefeed-treatment="preserve" as your container element might suffice, see https://www.w3.org/TR/xsl11/#linefeed-treatment.

How to create a text formatter

I have this code
.large
My First Document
.normal
.paragraph
This is my
.italics
very first
.regular
document, and I am very proud that I am getting this on the string. While this paragraph is not filled, the following one has automatic filling set:
.paragraph
.indent
.fill
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
.nofill
.outdent
Well, that was
.bold
exciting
.regular
good luck!
and I need to be able to enter this and it executes the above commands (that start with .) and prints out the text then saves it to a PDF.
The commands are:
- .paragraph Starts a new paragraph
- .fill enables sets indentation to fill for paragrahs, where the last character of a line must
end at the end of the margin (except for the last line of a paragarph)
- .nofill the default, sets the formatter to regular formatting
- .regular resets the font to the normal font
- .italic sets the font to italic
- .bold sets the font to bold
- .indent indents the text by a tab (or equivalent)
- .outdent outdents the text by a tab (or equivalent)
Any idea how I'd go about this? Incredibly stuck at the moment.

Issue Using SQL Replace Function with Variable

Essentially, I'm trying to loop through the contents of #sprocs variable, implement the replace function, and print the respective changes. When I execute the code, the #spname variable is printed off, just not with the expected result.
declare #sprocs cursor
declare #spname nvarchar(max)
set #sprocs = cursor for
select ROUTINE_DEFINITION
from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE = 'Procedure' AND
ROUTINE_DEFINITION like '%someString%'
open #sprocs
fetch next from #sprocs into #spname
while ##FETCH_STATUS = 0
Begin
set #spname = replace(#spname, '%someString%', 'Hello')
print #spname
fetch next from #sprocs into #spname
end
Expected result would look like this:
Before
Lorem ipsum dolor sit amet, someString adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco someString nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. someString sint occaecat cupidatat non someString, sunt in culpa qui officia deserunt mollit anim id est laborum.
After
Lorem ipsum dolor sit amet, Hello adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco Hello nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Hello sint occaecat cupidatat non Hello, sunt in culpa qui officia deserunt mollit anim id est laborum.
I thought - initially - that is might be an issue with #spname variable type, but since it's declared as an nvarchar(max), I can't see that being the issue.
What's preventing the expected print out?
In addition to not using wildcards in your searchstring, you also really don't need a cursor for this. SQL works on the basis of data sets and applies anything you do in a standard select statement to all rows that are returned.
In light of this, your statement should just be:
select ROUTINE_DEFINITION
,replace(ROUTINE_DEFINITION,'someString','Hello') as ReplacedValues
from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE = 'Procedure'
and ROUTINE_DEFINITION like '%someString%'
which will apply the replace function to each and every value of ROUTINE_DEFINITION returned by the query.

PostgreSQL Pick one single random row from multiple tables

How can we pick a random row from 3 tables, whereas the table row count for each table may vary. This would need to be fair if there not same count. This means if one table had only one row and the other table has 10 rows, then were much more likely get row from table with 10 rows. Each row in all tables get chance at winning
I was trying to convert this SQL code which I got from another Stack Overflow post here
SELECT preview_id, review_id
FROM (
select preview.*, row_number() over (order by newid()) as seqnum from
preview
) preview
JOIN (
select review.*, row_number() over (order by newid()) as seqnum
from review
) review ON preview.seqnum = review.seqnum;
3 Table schemas.
CREATE TABLE preview
(
preview_id SERIAL PRIMARY KEY NOT NULL,
preview_header VARCHAR(90) NOT NULL,
preview_text TEXT NOT NULL
);
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header One', '"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Two', '"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don''t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn''t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Three', '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Four', '"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?" );
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Five', '"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Six', '"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.");
CREATE TABLE article
(
article_id SERIAL PRIMARY KEY NOT NULL,
article_header VARCHAR(90) NOT NULL,
article_text TEXT NOT NULL
);
SELECT * FROM article;
INSERT INTO article(article_header, article_text) VALUES ('Article Header One', '"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Two', '"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don''t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn''t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Three', '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Four', '"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Five', '"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Six', '"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.");
CREATE TABLE review
(
review_id SERIAL PRIMARY KEY NOT NULL,
review_header VARCHAR(90) NOT NULL,
review_text TEXT NOT NULL
);
INSERT INTO review(review_header, review_text) VALUES ('Preview Header One', '"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains." );
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Two', '"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don''t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn''t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.");
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Three', '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." );
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Four', '"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?");
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Five', '"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" );
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Six', '"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.");
The desired result will be a single full row from any one these tables. So each row has a fair chance at been the winner
If tables has similar structure just use UNION ALL
SELECT *,
row_number() over (order by newid()) as seqnum
FROM ( SELECT preview.* FROM preview
UNION ALL
SELECT review.* FROM review
) T
if doesnt have similar structure you need to do some tricks to make the union with same number of columns.
SELECT *,
row_number() over (order by newid()) as seqnum
FROM ( SELECT 'preview' as `source`, p.field1, p.field2, null , null
FROM preview P
UNION ALL
SELECT 'review' as `source`, null , null , r.field1, r.field2
FROM review R
) T
EDIT: for you new request
SELECT *, row_number() over (order by random()) as seqnum
FROM (SELECT 'preview' as `source`, preview_id as winning_id
FROM `preview`
UNION ALL
SELECT 'article' as `source`, article_id
FROM `preview`
UNION ALL
SELECT 'review' as `source`, review_id
FROM `preview`
) T
--LIMIT 1;